package xj.app;

import java.awt.*; 
import javax.swing.*; 
import org.jdesktop.swingx.*;

public class ClosablePanel {

  protected String name;
  
  protected boolean closable = false;
  
  protected boolean closed = false; 
 
  protected boolean detachable = false;
  
  protected boolean detached = false; 
  
  protected JComponent component;
  
  protected Icon icon;
  
  protected String title;

  protected int vpos, hpos; 
  
  // preferred width & height
  protected int width, height;  		

  // preferred width & height for detached window
  protected int detachedWidth, detachedHeight;  

  public ClosablePanel(String name, 
      		       JComponent component, 
      		       Icon icon,
      		       String title) {
    this.name = name;
    this.component = component;
    this.icon = icon;
    this.title = title;
  }
  
  public ClosablePanel(String name, 
		       JComponent component, 
		       String title) {
    this.name = name;
    this.component = component;
    this.title = title;
  }

  public ClosablePanel(String name) { 
    this.name = name;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public boolean isClosable() {
    return closable;
  }

  public void setClosable(boolean closable) {
    this.closable = closable;
  }

  public boolean isClosed() {
    return closed;
  }

  public void setClosed(boolean closed) {
    this.closed = closed;
  }

  public JComponent getComponent() {
    return component;
  }

  public void setComponent(JComponent component) {
    this.component = component;
  }

  public Container getContentContainer() { 
    if (component instanceof JXTitledPanel) { 
      JXTitledPanel tp = (JXTitledPanel) component;  
      return tp.getContentContainer();
    }  
    return null; 
  }

  public void setContentContainer(Container cont) { 
    if (cont != null && 
	component instanceof JXTitledPanel) { 
      JXTitledPanel tp = (JXTitledPanel) component;  
      tp.setContentContainer(cont);
    }
  }

  public Icon getIcon() {
    return icon;
  }

  public void setIcon(Icon icon) {
    this.icon = icon;
  }

  public String getTitle() {
    return title;
  }

  public void setTitle(String title) {
    this.title = title;
  }

  public void setPosition(int vpos, int hpos) { 
    this.vpos = vpos; 
    this.hpos = hpos; 
  }

  public int getVPosition() { 
    return vpos; 
  }

  public int getHPosition() { 
    return hpos; 
  }

  public boolean isDetachable() {
    return detachable;
  }

  public void setDetachable(boolean detachable) {
    this.detachable = detachable;
  }

  public boolean isDetached() {
    return detached;
  }

  public void setDetached(boolean detached) {
    this.detached = detached;
  }

  public int getWidth() {
    return width;
  }

  public void setWidth(int width) {
    this.width = width;
  }

  public int getHeight() {
    return height;
  }

  public void setHeight(int height) {
    this.height = height;
  }

  public int getDetachedWidth() {
    return detachedWidth;
  }

  public void setDetachedWidth(int detachedWidth) {
    this.detachedWidth = detachedWidth;
  }

  public int getDetachedHeight() {
    return detachedHeight;
  }

  public void setDetachedHeight(int detachedHeight) {
    this.detachedHeight = detachedHeight;
  }

}
